unit UCreditoFornecedor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFomCadastro, StdCtrls, DBCtrls, ToolEdit, RXDBCtrl, Mask,
  CurrEdit, Buttons, ExtCtrls, DB, DBTables, DBClient, Provider, Menus,
  ComCtrls, Grids, DBGrids;

type
  TFCreditoFornecedor = class(TFormCadastro)
    Panel4: TPanel;
    Label11: TLabel;
    Label12: TLabel;
    Label14: TLabel;
    DBText4: TDBText;
    DBText7: TDBText;
    DBText6: TDBText;
    Label13: TLabel;
    DBText5: TDBText;
    GBCredito: TGroupBox;
    Label39: TLabel;
    Label1: TLabel;
    Label40: TLabel;
    Label2: TLabel;
    RxDBCLimiteCredito: TRxDBCalcEdit;
    DBDData: TDBDateEdit;
    RxDBCCredito: TRxDBCalcEdit;
    DBMObsLimite: TDBMemo;
    QFornecedor: TQuery;
    DSFornecedor: TDataSource;
    procedure FormCreate(Sender: TObject);
    procedure BtnEditarClick(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
    procedure BtnCancelarClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BtnConsutaClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCreditoFornecedor: TFCreditoFornecedor;

implementation

uses UGestao, UDmGestao, UDMGeral, UGeral, UPesquisaRapida;

{$R *.dfm}

procedure TFCreditoFornecedor.FormCreate(Sender: TObject);
begin
  inherited;
  DSFornecedor.DataSet.Open;
end;

procedure TFCreditoFornecedor.BtnEditarClick(Sender: TObject);
begin
  inherited;
  DSFornecedor.DataSet.Edit;
  RxDBCCredito.Enabled := false;
end;

procedure TFCreditoFornecedor.BtnSalvarClick(Sender: TObject);
begin
  inherited;
  DSFornecedor.DataSet.Post;
end;

procedure TFCreditoFornecedor.BtnCancelarClick(Sender: TObject);
begin
  inherited;
  DSFornecedor.DataSet.Cancel;
end;

procedure TFCreditoFornecedor.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  FCreditoFornecedor := nil;
  Action := caFree;
end;

procedure TFCreditoFornecedor.BtnConsutaClick(Sender: TObject);
begin
  inherited;
    Application.CreateForm(TFPesquisaRapida,FPesquisaRapida);

  FPesquisaRapida.tipo    := 'FORNECEDOR';
  CaPtUrA_pEsQuIsA_rApIdA := '';

  FPesquisaRapida.ShowModal;

  if CaPtUrA_pEsQuIsA_rApIdA <> '' then
    QFornecedor.Locate('FORN_CODIGO',CaPtUrA_pEsQuIsA_rApIdA,[]);

  CaPtUrA_pEsQuIsA_rApIdA := '';

  Exit;

end;

end.
